]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
panel: Add quick settings indicator
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 24 Jul 2022 17:49:58 +0000 (19:49 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 2 Aug 2022 16:05:28 +0000 (16:05 +0000)
The new indicator will eventually expose all the system status
items that are currently provided by the aggregate menu, but in
a more accessible form than the current submenu-heavy menu.

Right now this just adds the new empty indicator to the top bar,
alongside the existing aggregate menu.

We can then move items over one-by-one.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2392>

js/ui/panel.js
js/ui/sessionMode.js

index 992cdd8e9326640396f485afbb7ee2f76ca1b40a..850d4f06c168ba87b6f03c17add00c6ed26e7226 100644 (file)
@@ -11,6 +11,7 @@ const DND = imports.ui.dnd;
 const Overview = imports.ui.overview;
 const PopupMenu = imports.ui.popupMenu;
 const PanelMenu = imports.ui.panelMenu;
+const {QuickSettingsMenu} = imports.ui.quickSettings;
 const Main = imports.ui.main;
 
 var PANEL_ICON_SIZE = 16;
@@ -18,6 +19,8 @@ var APP_MENU_ICON_MARGIN = 0;
 
 var BUTTON_DND_ACTIVATION_TIMEOUT = 250;
 
+const N_QUICK_SETTINGS_COLUMNS = 2;
+
 /**
  * AppMenuButton:
  *
@@ -432,10 +435,29 @@ class AggregateMenu extends PanelMenu.Button {
     }
 });
 
+var QuickSettings = GObject.registerClass(
+class QuickSettings extends PanelMenu.Button {
+    _init() {
+        super._init(0.0, C_('System menu in the top bar', 'System'), true);
+
+        this._indicators = new St.BoxLayout({
+            style_class: 'panel-status-indicators-box',
+        });
+        this.add_child(this._indicators);
+
+        this.setMenu(new QuickSettingsMenu(this, N_QUICK_SETTINGS_COLUMNS));
+    }
+
+    _addItems(items, colSpan = 1) {
+        items.forEach(item => this.menu.addItem(item, colSpan));
+    }
+});
+
 const PANEL_ITEM_IMPLEMENTATIONS = {
     'activities': ActivitiesButton,
     'aggregateMenu': AggregateMenu,
     'appMenu': AppMenuButton,
+    'quickSettings': QuickSettings,
     'dateMenu': imports.ui.dateMenu.DateMenuButton,
     'a11y': imports.ui.status.accessibility.ATIndicator,
     'keyboard': imports.ui.status.keyboard.InputSourceIndicator,
index acf584d8c99c3fe645727309566f33f15194fd48..c82e8329c9e0b4c35a6d6aca68f21e7332f5d853 100644 (file)
@@ -59,7 +59,7 @@ const _modes = {
         panel: {
             left: [],
             center: ['dateMenu'],
-            right: ['dwellClick', 'a11y', 'keyboard', 'aggregateMenu'],
+            right: ['dwellClick', 'a11y', 'keyboard', 'quickSettings', 'aggregateMenu'],
         },
         panelStyle: 'login-screen',
     },
@@ -71,7 +71,7 @@ const _modes = {
         panel: {
             left: [],
             center: [],
-            right: ['dwellClick', 'a11y', 'keyboard', 'aggregateMenu'],
+            right: ['dwellClick', 'a11y', 'keyboard', 'quickSettings', 'aggregateMenu'],
         },
         panelStyle: 'unlock-screen',
     },
@@ -94,7 +94,7 @@ const _modes = {
         panel: {
             left: ['activities', 'appMenu'],
             center: ['dateMenu'],
-            right: ['screenRecording', 'screenSharing', 'dwellClick', 'a11y', 'keyboard', 'aggregateMenu'],
+            right: ['screenRecording', 'screenSharing', 'dwellClick', 'a11y', 'keyboard', 'quickSettings', 'aggregateMenu'],
         },
     },
 };